<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib uri="/WEB-INF/html.tld" prefix="html"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>

<c:url var="url" value="/application/asset_add" />
<c:url var="calculateAndSave" value="/application/calculateAndSave" />
<div id='applicaton_form'>
			<div class="content-backgroud">
				
<form:form id="applicationForm" modelAttribute="application"
					method="POST" action="${url}" name="applicationForm">

		<jsp:include page="asset_selection.jsp"></jsp:include>
  		<jsp:include page="application_assets.jsp"></jsp:include>
  		<jsp:include page="financingOptions.jsp"></jsp:include>
  		
  		<form:hidden path="application.applicationId" name="application.applicationId" />
</form:form>
</div>
</div>


	<script>
	
	function saveApplicationAsset()
	{
		
		
		jQuery.ajaxSettings.traditional = true;

		var formData = $("#applicationForm").serializeObject();
		
		//alert(JSON.stringify(formData));
		var params={url:"${url}",complete:onComplete,error:onError,success:onSuccess,data:formData,type:"POST",dataType:"JSON"};
		doAjax(params);
		
	}
	
	function onComplete()
	{}
	function onSuccess(result)
	{
		
		var formData = $("#applicationForm").serializeObject();
		$( "div#applicationAssets" ).pqGrid( "refreshDataAndView" );
		 $("#applicationForm").clear();
	
	}
	function onError()
	{}
	function calculate()
	{
		jQuery.ajaxSettings.traditional = true;

		var formData = $("#applicationForm").serializeObject();
		
		//alert(JSON.stringify(formData));
		var params={url:"${calculateAndSave}",complete:onComplete,error:onError,success:onSuccess,data:formData,type:"POST",dataType:"JSON"};
		doAjax(params);
	}
	
	</script>
 